package com.ruoyi.gaokao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gaokao.domain.GkForeignLanguage;
import com.ruoyi.gaokao.service.IGkForeignLanguageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 外语考试语种Controller
 * 
 * @author xiaosong
 * @date 2025-07-07
 */
@Api(tags = "高考-外语语种管理")
@RestController
@RequestMapping("/gaokao/GkForeignLanguage")
public class GkForeignLanguageController extends BaseController
{
    @Autowired
    private IGkForeignLanguageService gkForeignLanguageService;

    /**
     * 查询外语考试语种列表
     */
    @PreAuthorize("@ss.hasPermi('gaokao:GkForeignLanguage:list')")
    @GetMapping("/list")
        @ApiOperation("高考外语语种管理 - 分页查询列表")
    public TableDataInfo list(GkForeignLanguage gkForeignLanguage)
    {
        startPage();
        List<GkForeignLanguage> list = gkForeignLanguageService.selectGkForeignLanguageList(gkForeignLanguage);
        return getDataTable(list);
    }

    // 查询全部数据
    @GetMapping("/all")
        @ApiOperation("高考外语语种管理 - 查询所有数据")
    public AjaxResult getAll(){
        List<GkForeignLanguage> list = gkForeignLanguageService.selectGkForeignLanguageAll();
        return success(list);
    }

    /**
     * 导出外语考试语种列表
     */
    @PreAuthorize("@ss.hasPermi('gaokao:GkForeignLanguage:export')")
    @Log(title = "外语考试语种", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
        @ApiOperation("高考外语语种管理 - 导出数据")
    public void export(HttpServletResponse response, GkForeignLanguage gkForeignLanguage)
    {
        List<GkForeignLanguage> list = gkForeignLanguageService.selectGkForeignLanguageList(gkForeignLanguage);
        ExcelUtil<GkForeignLanguage> util = new ExcelUtil<GkForeignLanguage>(GkForeignLanguage.class);
        util.exportExcel(response, list, "外语考试语种数据");
    }

    /**
     * 获取外语考试语种详细信息
     */
//    @PreAuthorize("@ss.hasPermi('gaokao:GkForeignLanguage:query')")
    @GetMapping(value = "/{id}")
        @ApiOperation("高考外语语种管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gkForeignLanguageService.selectGkForeignLanguageById(id));
    }

    /**
     * 新增外语考试语种
     */
    @PreAuthorize("@ss.hasPermi('gaokao:GkForeignLanguage:add')")
    @Log(title = "外语考试语种", businessType = BusinessType.INSERT)
    @PostMapping
        @ApiOperation("高考外语语种管理 - 新增数据")
    public AjaxResult add(@RequestBody GkForeignLanguage gkForeignLanguage)
    {
        return toAjax(gkForeignLanguageService.insertGkForeignLanguage(gkForeignLanguage));
    }

    /**
     * 修改外语考试语种
     */
    @PreAuthorize("@ss.hasPermi('gaokao:GkForeignLanguage:edit')")
    @Log(title = "外语考试语种", businessType = BusinessType.UPDATE)
    @PutMapping
        @ApiOperation("高考外语语种管理 - 修改数据")
    public AjaxResult edit(@RequestBody GkForeignLanguage gkForeignLanguage)
    {
        return toAjax(gkForeignLanguageService.updateGkForeignLanguage(gkForeignLanguage));
    }

    /**
     * 删除外语考试语种
     */
    @PreAuthorize("@ss.hasPermi('gaokao:GkForeignLanguage:remove')")
    @Log(title = "外语考试语种", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
        @ApiOperation("高考外语语种管理 - 删除数据")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gkForeignLanguageService.deleteGkForeignLanguageByIds(ids));
    }
}
